<?PHP
// vim: set expandtab tabstop=4 shiftwidth=4:
// +----------------------------------------------------------------------+
// | Communicator for the SAPID CMS                               		  |
// +----------------------------------------------------------------------+
// | Author:  Dmitry Sheiko (www.cmsdevelopment.com)	                  |
// | Copyright (c) 2004 Dmitry Sheiko	                                  |
// | http://sapid.sourceforge.net	                                      |
// +----------------------------------------------------------------------+
// | This source file is free software; you can redistribute it and/or    |
// | modify it under the terms of the GNU Lesser General Public           |
// | License as published by the Free Software Foundation; either         |
// | version 2.1 of the License, or (at your option) any later version.   |
// |                                                                      |
// | This source file is distributed in the hope that it will be useful,  |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    |
// | Lesser General Public License for more details.                      |
// +----------------------------------------------------------------------+
// Release: 18.11.04 (dd/mm/yy)
// $Id: index.php,v 1.1.1.1 2005/06/13 07:20:28 mephius Exp $

include ("../../../etc/rc.conf.php");
$root_path = preg_replace("/usr.system.communicator.index\.php$/is", "", $root_path);
$root_path = preg_replace("/usr.system.communicator.$/is", "", $root_path);
$root_path = preg_replace("/\/\//", "/", $root_path);
include($root_path."etc/rc.d/debug.inc.php");
include($root_path."kernel/vdb.lib.php");

if($default_language=="ru")
	include ($root_path."lang/ru.inc.php");
else
	include ($root_path."lang/en.inc.php");
	
	$vdb = new sapi_vdb();

	$server_path = "http://xmlsapiens.org/communicator/";
	/*
	if (!@fsockopen($server_path, 80)) {
		message_die("Couldn't connect to messaging server!", "Error");
	}
	*/
	
	
// Get setup data	
$objdata = $vdb->get_data($root_path."usr/xml/vdb/common.cfg.xml");
if($objdata) { foreach($objdata as $common) {}}	

	if($_GET["id_of_user"] AND !$common["ID_OF_USER"]) {
		$_POST["post_action"] = "CHANGEROW";
		$_POST["row"] = $common;
		$common["ID_OF_USER"] = $_POST["row"]["ID_OF_USER"] = $_GET["id_of_user"];
		$vdb->save_data_row($root_path."usr/xml/vdb/common.cfg.xml", false, false);	
	}

	
	if(!$common["ID_OF_USER"] OR $_GET["action"]=="register" AND $DEMO_MODE!="enabled") 
		include ("registration_form.inc.php");
	else
		include ("chat_form.inc.php");
?>